package cn.batch.daemon.jdbc;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import cn.batch.daemon.util.JdbcUtils;

import com.skyon.core.config.BaseJNDIEnv;
import com.skyon.core.jdbc.ConnectionProvider;

public class PreparApprovalStore {
	private static Log logger = LogFactory.getLog(PreparApprovalStore.class);

	private static ConnectionProvider connectionProvider;

	public static void init() {
		BaseJNDIEnv.init();
		connectionProvider = new JdbcConnectionOracleProvider();
	}
	
	/**
     * 预审批批量处理--获得待处理的客户数据
     * 
     * @return List 
     * @throws Exception 
     */
	public static List getAppCustInfo() throws Exception{
		init();
        Connection connection = null;
        Statement statement = null;
        ResultSet rs = null;
        String completeDay = null;
        List l = new ArrayList();
        String sql = "SELECT min(CODE_NAME) FROM BATCH_CODE_LIST where CODE_ID='1' and BATCH_FLAG='0'";
        try{
            connection = connectionProvider.getConnection();
            statement = connection.createStatement();
            rs = statement.executeQuery(sql);
            
            while(rs.next()){
            	completeDay = rs.getString(1).trim();
            }
            l.add(completeDay);
        }catch(Exception e){
            logger.error("ERROR QUERY SQL:" + sql, e);
            throw e;
        }finally{
        	JdbcUtils.closeResultSet(rs);
        	JdbcUtils.closeStatement(statement);
        	JdbcUtils.closeConnection(connection);
        }
        return l;
	}
}
